/*
 * Copyright 2014 Graham Smith
 */
package uk.co.wobblycogs.vegas.riff;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Vegas seems to differentiate between different types of media file but it's
 * not clear exactly what it uses to decide type.
 * <ul>
 * <li>Type 1 seems to be MP3 and MP4 files.</li>
 * <li>Type 3 is generated media.</li>
 * <li>Type 8 is also MP4 files.</li>
 * <li>Type 9 is AVCHD (MTS / M2TS) files.</li>
 * </ul>
 *
 * @author Graham Smith
 */
public enum ResourceType {

	FILE(new int[]{1, 8, 9}), GENERATED(3);

	private final Set<Integer> resourceType = new HashSet<>();

	private ResourceType(int resourceType) {
		this(new int[]{resourceType});
	}

	private ResourceType(int[] resourceType) {
		this.resourceType.addAll(Arrays.stream(resourceType).boxed().collect(Collectors.toList()));
	}

	public Set<Integer> getResourceType() {
		return resourceType;
	}

	public static ResourceType getResourceType(Integer type) {
		for (ResourceType r : ResourceType.values()) {
			if (r.getResourceType().contains(type)) {
				return r;
			}
		}
		return null;
	}

}
